@{
    Layout = "_Layout.cshtml";


    var c = ViewContext.RouteData.Values["Controller"].ToString();
    
    var h = 500;
    if (c == "user"|| c == "hobby") {h = 300;}
    if (c == "country") { h = 200; }
    var he = h;
}

@Html.Partial("header")
@Html.Confirm("Are you sure you want to delete this " + c + " ?")
@Html.MakePopupForm("create", title: "create " + c, successFunction: "create", height: h)
@Html.MakePopupForm("Edit", new[] { "id" }, title: "edit " + c, successFunction: "edit", height: he)

<script type="text/javascript">
    var page = 1;
    function addStart(d) { $(d).css('opacity', 0).prependTo("#list").animate({ opacity: 1 }, 600, 'easeInCubic'); }
    function addEnd(d) { $(d).css('opacity', 0).appendTo("#list").animate({ opacity: 1 }, 300, 'easeInCubic'); }

    function create(o) { $.get('@Url.Action("row")', { id: o.Id }, function (d) { addStart(d); }); }
    function edit(o) { $.get('@Url.Action("row")', { id: o.Id }, function (d) { $("#o" + o.Id).before(d).remove(); $("#o" + o.Id).hide().fadeIn('slow'); }); }
    var lfm;
    $(function () {
        regForm();
        $(this).ajaxComplete(regForm);
        $('#more').click(more);
        $('#sform').ajaxForm({ success: function (d) {
            $("#list").html(d.rows);
            page = 1;
            if (d.more) $('#more').show(); else $('#more').hide();
            lfm = $('#sform').formSerialize();
        }
        }).submit();
        ae_interactive('#sform');
    });

    function regForm() {
        $(".fconfirm").ajaxForm({ success: function (d) { $('#o' + d.Id).fadeOut('slow', function () { $(this).remove(); styleup(); }); } });
    }

    function more() {
        page++;
        $.post('@Url.Action("search")', lfm + '&page=' + page, function (d) {
            addEnd(d.rows);
            if (d.more) $('#more').show(); else $('#more').fadeOut('slow');
        });
    }        
</script>
<form id="sform" action="@Url.Action("search")" method="post">
@Html.Partial("searchbox")
</form>
<br />
@Html.PopupFormActionLink("create", htmlAttributes: new { @class = "abtn" })
<br />
<br />
<table class="atbl">
    <thead>
        @Html.Partial("hrow")
    </thead>
    <tbody id="list">
    </tbody>
</table>
<br />
<a id="more" class="abtn" style="display:none;">more</a> 